import java.io.FileNotFoundException;

public class CsvReader {
    static {
        System.loadLibrary("csv");
    }

    private native long newCsvLoader(String path);
    private native void freeCsvLoader(long csvLoader);
    private native String[] cReadRow(long csvLoader);
    private native long cSize(long csvLoader);

    private long cObject;

    public CsvReader(String path) throws FileNotFoundException {
        cObject = newCsvLoader(path);
        if (cObject == 0) throw new FileNotFoundException(path);
    }

    public void close() {
        if (cObject == 0) throw new NullPointerException();
        freeCsvLoader(cObject);
    }

    public String[] readRow() {
        return cReadRow(cObject);
    }

    public long size() {
        return cSize(cObject);
    }
}
